<template>
	<view>
		<view v-for="(item,index) in brandDataLists" :key="index">
			<view class="title-view-selectBrandName pad28-8-6 bac-F4">{{item.name}}</view>
			<view v-for="(item2,index2) in item.children" :key="index2">
				<view class="item-box" @click="click_item(item2,item.id)">
					<view class="text-name pad28-38 marginLeft28">{{item2.name}}</view>
					<view class="line"></view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		getUsedVehicleSeries,
		getUsedSearchSeries,
		getUsedSearchModels,
		getUsedVehicleSeriesSecondary
	} from '@/api/brand.js'
	export default {
		data() {
			return {
				brandDataLists: [],
				brand_type: 'search',
				brand_id: '',
				brand_name: ''

			}
		},
		onLoad(option) {
			if (option.name) {
				uni.setNavigationBarTitle({
					title: option.name
				});
				this.brand_name = option.name
			}
			var that = this
			this.brand_id = option.brand_id
			that.brandDataLists = []
			if (option.brand_type == 'search') {
				this.brand_type = 'search'
				getUsedSearchSeries(option.brand_id).then(res => {
					that.$utils.log("打印寻车车系数据  " + JSON.stringify(res))
					if (res.code == 0) {
						that.$nextTick(() => {
							that.brandDataLists = res.data
							that.$forceUpdate()
						})
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
					}
				})
			} else {
				this.brand_type = 'secondhand'
				getUsedVehicleSeries(option.brand_id, '').then(res => {
					that.$utils.log("打印二手车车系数据  " + JSON.stringify(res))
					if (res.code == 0) {
						that.$nextTick(() => {
							that.brandDataLists = res.data
							that.$forceUpdate()
						})
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
					}
				})
			}
		},
		methods: {
			click_item(item, series_one_id) {
				var that = this
				that.$utils.log("打印 brand_type  " + this.brand_type)

				uni.navigateTo({
					url: '/pages/home/selectBrand/selectBrand3More/selectBrand3More?name=' +
						item.name + "&series_id=" +
						item.id + "&brand_type=" + that.brand_type + '&brand_id=' + that.brand_id +
						'&series_one_id=' + series_one_id + '&brand_name=' + this.brand_name
				})

			}
		}
	}
</script>

<style>
	page {
		background-color: white;
	}

	.title-view-selectBrandName {
		font-size: 28rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #1C2125;
		opacity: 1;
	}

	.title {
		font-size: 28rpx;
		font-family: DIN Alternate;
		font-weight: bold;
		color: #1C2125;
	}

	.pad28-8-6 {
		padding: 8rpx 0px 6rpx 28rpx;
	}

	.marginLeft28 {
		margin-left: 38rpx;
	}

	.pad28-38 {
		padding: 28rpx 0rpx;
	}

	.margin28 {
		margin: 28rpx;
	}

	.bac-F4 {
		background-color: #F4F4F4;
	}

	.text-name {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #000026;
		width: 100%;
		text-align: left;
	}

	.line {
		width: 695rpx;
		height: 0rpx;
		border: 1px solid #000000;
		opacity: 0.03;
	}

	.item-box {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}
</style>